<?php
class Admin_SectionController extends My_Controllers_Admin {
	public function indexAction() {
		$this->view->setHelperPath ( './application/views/helpers', 'My_View_Helper' );
		
		$id = $this->_getParam ( 'id' );
		if (! $id) {
			$auth = Zend_Auth::getInstance ();
			$id = $auth->getIdentity ()->ke_id;
		}
		
		$keshi = new Keshi ( );
		$this->view->keshi = $keshi->find ( $id )->current ();
		Zend_Debug::dump ( $this->view->keshi, "keshi", false );
		if ($this->_request->isPost ()) {
			$getDb = $this->_getAllParams ();
			unset ( $getDb ['module'] );
			unset ( $getDb ['controller'] );
			unset ( $getDb ['action'] );
			Zend_Debug::dump ( $getDb, "getDb", false );
			$where = $keshi->getAdapter ()->quoteInto ( 'id = ?', $id );
			$keshi->update ( $getDb, $where );
			if ($this->_getParam ( 'id' )) {
				$this->_redirect ( "/admin/section/list" );
			} else {
				$this->_redirect ( "/admin/section" );
			}
		}
	}
	public function listAction() {
		$db = Zend_Registry::get ( 'db' );
		$select = new Zend_Db_Select ( $db );
		$select->from ( 'bc_keshi', array ('kename', 'id', 'leibie_id' ) );
		$sql = $select->__toString ();
		$this->view->d = $db->fetchAll ( $sql );
	}
}

?>